package com.rslai.base.tool.servertest;

import com.rslai.base.tool.servertest.context.Context;
import com.rslai.base.tool.servertest.model.TestCase;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import org.apache.commons.lang.StringUtils;
import org.junit.runners.model.FrameworkMethod;

public class ServertestFrameworkMethod extends FrameworkMethod {
    private TestCase testCase;
    private Context context;

    public ServertestFrameworkMethod(Method method, TestCase testCase, Context context) {
        super(method);
        this.testCase = testCase;
        this.context = context;
    }

    public String getName() {
        return getName(this.testCase);
    }

    private String getName(TestCase testCase) {
        if (StringUtils.isNotBlank(testCase.getDesc())) {
            return testCase.getDesc();
        }
        return testCase.getId();
    }

    public Annotation[] getAnnotations() {
        return new Annotation[0];
    }

    public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
        return null;
    }

    public TestCase getTestCase() {
        return this.testCase;
    }

    public Context getContext() {
        return this.context;
    }
}
